﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ling
{
    public partial class Form1 : Form
    {
        Random ra = new Random();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            sort.Text = "";
            List<int> li = new List<int>();
            for (int i = 0; i < 100; i++)
            {
                li.Add(ra.Next(1000));
            }
            var query = 
                from i in li 
                orderby i descending 
                select i;
            foreach (var i in query)
            {
                sort.Text += i + " ";
            }
            int sums = query.Sum();
            double aves = query.Average();
            sort.Text += "\r\n" ;
            sum.Text = sums.ToString();
            ave.Text = aves.ToString();
        }
    }
}


           


